package com.api.shopapi.service.impl;

import com.api.shopapi.entity.JKDanguchun;
import com.api.shopapi.entity.dto.JKDanguchunDTO;
import com.api.shopapi.mapper.JKDanguchunMapper;
import com.api.shopapi.service.JKDanguchunService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("JKDanguchunServiceImplOne")
public class JKDanguchunServiceImpl implements JKDanguchunService {

    @Autowired
    private JKDanguchunMapper jkDanguchunMapper;

    @Override
    public int insert(JKDanguchun jkDanguchun) {
        return jkDanguchunMapper.insert(jkDanguchun);
    }

    @Override
    public int update(JKDanguchun jkDanguchun) {
        return jkDanguchunMapper.update(jkDanguchun);
    }

    @Override
    public int delete(String jkDanguchunCode) {
        return jkDanguchunMapper.delete(jkDanguchunCode);
    }

    @Override
    public JKDanguchun getByJkDanguchunCode(String jkDanguchunCode) {
        return jkDanguchunMapper.getByJKDanguchunCode(jkDanguchunCode);
    }

    @Override
    public PageInfo<JKDanguchun> getPageList(int pageIndex, int pageSize, String userCode,String startTime,String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKDanguchun> jkDanguchunList = jkDanguchunMapper.getPageList(userCode,startTime,endTime);
        return new PageInfo<>(jkDanguchunList);
    }

    @Override
    public PageInfo<JKDanguchunDTO> getAdmPageList(int pageIndex, int pageSize, String name, String governmentCode, String startTime, String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKDanguchunDTO> jkDanguchunDTOList = jkDanguchunMapper.getAdmPageList(name, governmentCode, startTime, endTime);
        return new PageInfo<>(jkDanguchunDTOList);
    }
}
